
(function (window) {

var args = [], functions = {};

var KC = function(expr, root) {
	if (typeof expr == 'string') {
		args = [KC.query(expr, root)];
	} else {
		args = [expr];
	}
	return functions;
};

function extend(key, val) {
	KC[key] = val;
	if (typeof val == 'function') {
		functions[key] = function() {
			for (var i = 0, len = arguments.length; i < len; i++) {
				args.push(arguments[i]);
			}
			var rtn = val.apply(KC, args);
			args = [args.shift()];
			return rtn;
		};
	}
}

KC.extend = function(key, val) {
	if (typeof key == 'object') {
		for (var k in key) extend(k, key[k]);
	} else {
		extend(key, val);
	}
};

KC.extend('browser', (function() {
	var ua = navigator.userAgent.toLowerCase();
	return {
		VERSION: ua.match(/(?:msie|firefox|webkit|opera)[\/:\s](\d+)/) ? RegExp.$1 : '0',
		IE: (ua.indexOf('msie') > -1 && ua.indexOf('opera') == -1),
		GECKO: (ua.indexOf('gecko') > -1 && ua.indexOf('khtml') == -1),
		WEBKIT: (ua.indexOf('applewebkit') > -1),
		OPERA: (ua.indexOf('opera') > -1)
	};
})());

window['KC'] = KC;

})(window);
